import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';

class SelectChoiceChip extends StatefulWidget {
  late String text;
  // late double height;
  late EdgeInsetsGeometry padding;
  late double fontSize;
  late Color textColor;
  late Color boxColor;
  late Color textSelectColor;
  late Color boxSelectColor;
  late BorderRadiusGeometry borderRadius;

  // late BoxBorder border;
  late BoxBorder selectBorder;
  late ValueChanged<bool> onSelect;
  late bool? selected;

  SelectChoiceChip(
      {required this.text,
      // this.height = 50,
      this.padding = const EdgeInsets.symmetric(horizontal: 14, vertical: 12),
      this.fontSize = 14,
      this.textColor = const Color(0xff222222),
      this.boxColor = const Color(0xffE2E8FD),
      this.textSelectColor = const Color(0xffffffff),
      this.boxSelectColor = const Color(0xff237BFC),
      this.borderRadius = const BorderRadius.all(Radius.circular(4)),
      // this.border=const Border.fromBorderSide(BorderSide(
      //           color: Color(0xFF535353), width: 1, style: BorderStyle.solid)),,
      // this.selectBorder,
      required this.onSelect,
      this.selected });

  @override
  State<StatefulWidget> createState() => SelectChoiceState();
}

class SelectChoiceState extends State<SelectChoiceChip> {
  @override
  Widget build(BuildContext context) {
    bool _select = widget.selected!;

    @override
    void initState() {
      super.initState();

    }
    return GestureDetector(
      onTap: () {
        widget.onSelect(!_select);
      },
      child: Container(
        // height: widget.height,
        padding: widget.padding,
        child: Text(
          widget.text,
          style: TextStyle(
              fontSize: widget.fontSize,
              color: _select ? widget.textSelectColor : widget.textColor),
        ),
        decoration: ShapeDecoration(
          color: _select ? widget.boxSelectColor : widget.boxColor,
          shape: RoundedRectangleBorder(
            borderRadius: widget.borderRadius
          ),
        ),
        /*decoration: BoxDecoration(
            color: _select ? widget.boxSelectColor : widget.boxColor,
            borderRadius: widget.borderRadius,
            // border: _select ? widget.selectBorder : widget.border
        ),*/
      ),
    );
  }
}
